{% extends "misago/admin/generic/form.html" %}
{% load i18n misago_admin_form misago_avatars misago_capture %}


{% block title %}
{% trans "Ban users" %} | {{ active_link.name }} | {{ block.super }}
{% endblock title %}


{% block form-header %}
{% trans "Ban selected users" %}
{% endblock %}


{% block form-body %}
<input type="hidden" name="action" value="ban">
{% for user in users %}
  <input type="hidden" name="selected_items" value="{{ user.pk }}">
{% endfor %}
<div class="form-fieldset pt-0">
  <fieldset>
    <legend>{% trans "Users" %}</legend>
    <div class="card card-admin-table">
      <table class="table">
        <thead>
          <tr>
            <th style="width: 1px;">&nbsp;</th>
            <th>{% trans "User" %}</th>
            <th style="width: 50%;">{% trans "E-mail" %}</th>
            <th style="width: 200px;">{% trans "IP address" %}</th>
          </tr>
        </thead>
        <tbody>
        {% for user in users %}
          <tr>
            <td class="pr-0">
              <a href="{{ user.get_absolute_url }}">
                <img src="{{ user|avatar:24 }}" alt="{% trans 'Avatar' %}" width="24" height="24">
              </a>
            </td>
            <td class="small">
              <a href="{{ user.get_absolute_url }}" class="item-name">{{ user }}</a>
            </td>
            <td class="small">
              <a href="mailto:{{ user.email }}">{{ user.email }}</a>
            </td>
            <td class="small">
              {% if user.joined_from_ip %}
                {{ user.joined_from_ip }}
              {% else %}
                <i class="text-muted">{% trans "IP removed" %}</i>
              {% endif %}
            </td>
          </tr>
        {% endfor %}
      </tbody>
    </table>
  </fieldset>
</div>
<div class="form-fieldset">
  <fieldset>
    <legend>{% trans "Ban settings" %}</legend>

    {% form_row form.ban_type %}
    {% form_row form.expires_on %}

  </fieldset>
</div>
<div class="form-fieldset">
  <fieldset>
    <legend>{% trans "Messages" %}</legend>

    {% form_row form.user_message %}
    {% form_row form.staff_message %}

  </fieldset>
</div>
{% endblock form-body %}


{% block form-footer %}
<button class="btn btn-primary btn-sm" name="finalize">{% trans "Ban users" %}</button>
{% endblock %}


{% block javascripts %}
<script type="text/javascript">
  window.misago.initDatepicker({
    elementId: "id_expires_on",
    never: "{% trans 'Never' %}",
    setDate: "{% trans 'Set date' %}"
  })
</script>
{% endblock %}
